﻿CREATE TABLE [dbo].[Unitati] (
    [CodUnitate]          SMALLINT      IDENTITY (0, 1) NOT NULL,
    [Denumire]            VARCHAR (50)  CONSTRAINT [DF_Unitati_Denumire] DEFAULT ('Nespecificat') NOT NULL,
    [UnitateSursa]        SMALLINT      CONSTRAINT [DF_Unitati_UnitateSursa] DEFAULT ((0)) NOT NULL,
    [CUI]                 DECIMAL (18)  NULL,
    [AtributFiscal]       VARCHAR (10)  NULL,
    [Adresa]              VARCHAR (200) NULL,
    [IBAN]                VARCHAR (50)  NULL,
    [IDBanca]             SMALLINT      NULL,
    [AgentieBancara]      VARCHAR (50)  NULL,
    [Telefon]             VARCHAR (50)  NULL,
    [Fax]                 VARCHAR (50)  NULL,
    [Email]               VARCHAR (150) NULL,
    [Reprezentant]        VARCHAR (150) NULL,
    [Cumulativa]          BIT           NULL,
    [CodUnitateParinte]   SMALLINT      NULL,
    [JudRegComert]        SMALLINT      NULL,
    [NrRegComert]         INT           NULL,
    [AnRegComert]         SMALLINT      NULL,
    [IDJudet]             INT           NULL,
    [CNPReprezentant]     DECIMAL (13)  NULL,
    [AdresaReprezentant]  VARCHAR (200) NULL,
    [TelefonReprezentant] VARCHAR (20)  NULL,
    [EmailReprezentant]   VARCHAR (100) NULL,
    [FunctieReprezentant] VARCHAR (100) NULL,
    [CapitalSocial]       INT           CONSTRAINT [DF_Unitati_CapitalSocial] DEFAULT ((0)) NULL,
    CONSTRAINT [PK_Unitati] PRIMARY KEY CLUSTERED ([CodUnitate] ASC) WITH (FILLFACTOR = 90),
    CONSTRAINT [FK_Unitati_Banci] FOREIGN KEY ([IDBanca]) REFERENCES [dbo].[Banci] ([IdBanca]),
    CONSTRAINT [FK_Unitati_Judete] FOREIGN KEY ([IDJudet]) REFERENCES [dbo].[Judete] ([IDJudet]),
    CONSTRAINT [FK_Unitati_Unitati] FOREIGN KEY ([UnitateSursa]) REFERENCES [dbo].[Unitati] ([CodUnitate]),
    CONSTRAINT [FK_Unitati_Unitati2] FOREIGN KEY ([CodUnitateParinte]) REFERENCES [dbo].[Unitati] ([CodUnitate])
);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Codul Unitatii', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Unitati', @level2type = N'COLUMN', @level2name = N'CodUnitate';

